""" System imports """
import os, sys
import logging

""" Other modules """
import pygame

""" Game """
import resourcemanager
from constants import *
from eventrouter import eventpanel
import inventory

""" Set up logging """
_log = logging.getLogger("epicquest.npc.npc")


class NPC(pygame.sprite.DirtySprite):
    
    def __init__(self, *args, **kwargs):    
        pygame.sprite.DirtySprite.__init__(self)
        self.coords = kwargs.get('coords', (0, 0))
        self.image = kwargs.get('image', None)
        self.rect = kwargs.get('rect', pygame.rect.Rect((self.coords[0] * TILE_WIDTH, self.coords[1] * TILE_HEIGHT),
                                                        (TILE_WIDTH, TILE_HEIGHT)))
        self.inventory = kwargs.get('inventory', inventory.Inventory())
        
        tilefont = pygame.font.SysFont("Courier New", 22)
        
        """ Setup default image """
        if self.image is None:
            npc_surf = tilefont.render("!", True, (255, 255, 255))
            image = pygame.surface.Surface((TILE_WIDTH, TILE_HEIGHT))
            image.blit(npc_surf, (0, 0))
            self.image = image
            
        self.dirty = 1
        self.layer = 1
        self.visible = 1
            
    def update(self, view_rect):
        if self.rect.colliderect(view_rect):
            self.dirty = 1

